furny.furndb
Class FurnCache

java.lang.Object
  extended by furny.furndb.FurnCache
All Implemented Interfaces:
FurnitureUpdateListener

public final class FurnCache
extends java.lang.Object
implements FurnitureUpdateListener

Simple cache that requests all furnitures from the database and stores them in a map. If a furniture is updated or deleted, the cache is refreshed.
This class is a SINGLETON.

Since:
10.08.2012
Author:
Stephan Dreyer

Field Summary
private  FurnDBManager dbManager
           
private  java.util.Map<java.lang.Long,Furniture> furnitures
           
private static FurnCache INSTANCE
           
 
Constructor Summary
private FurnCache()
          Private constructor for single instance.
 
Method Summary
 void furnitureDeleted(java.lang.Long id)
          This method will be notified if a furniture is updated.
 void furnitureIdsUpdated(java.util.List<java.lang.Long> ids)
          This method will be notified if a list of furnitures are updated.
 void furnitureUpdated(java.lang.Long id, Furniture furniture)
          This method will be notified if a furniture is updated.
 java.util.List<Furniture> getAllFurnitures()
          Getter for a list of a cached furnitures.
 Furniture getFurniture(java.lang.Long id)
          Getter for a furniture.
static FurnCache getInstance()
          Getter for the single instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

private static final FurnCache INSTANCE

furnitures

private final java.util.Map<java.lang.Long,Furniture> furnitures

dbManager

private final FurnDBManager dbManager
Constructor Detail

FurnCache

private FurnCache()
Private constructor for single instance.

Since:
10.08.2012
Method Detail

getInstance

public static FurnCache getInstance()
Getter for the single instance.

Returns:
Single instance of this cache.
Since:
10.08.2012

furnitureUpdated

public void furnitureUpdated(java.lang.Long id,
                             Furniture furniture)
Description copied from interface: FurnitureUpdateListener
This method will be notified if a furniture is updated.

Specified by:
furnitureUpdated in interface FurnitureUpdateListener
Parameters:
id - The id of the furniture.
furniture - The furniture

furnitureIdsUpdated

public void furnitureIdsUpdated(java.util.List<java.lang.Long> ids)
Description copied from interface: FurnitureUpdateListener
This method will be notified if a list of furnitures are updated.

Specified by:
furnitureIdsUpdated in interface FurnitureUpdateListener
Parameters:
ids - The list of furniture ids.

furnitureDeleted

public void furnitureDeleted(java.lang.Long id)
Description copied from interface: FurnitureUpdateListener
This method will be notified if a furniture is updated.

Specified by:
furnitureDeleted in interface FurnitureUpdateListener
Parameters:
id - The id of the furniture.

getAllFurnitures

public java.util.List<Furniture> getAllFurnitures()
Getter for a list of a cached furnitures.

Returns:
A list of all furnitures.
Since:
10.08.2012

getFurniture

public Furniture getFurniture(java.lang.Long id)
Getter for a furniture.

Parameters:
id - The id of the furniture.
Returns:
The furniture that belongs to the id.
Since:
10.08.2012